package com.akaovi.common.util;

import com.akaovi.common.selfexception.LessThanZero;
import com.akaovi.common.selfexception.NotTriangle;

import java.io.NotActiveException;
import java.util.Scanner;

/**
 * @author akaovi
 * @version 1.0
 * @description
 * @date 2022/10/31 14:23
 * @since 2022/10/31 14:23
 */
public class Utils {
    private static final Scanner scan = new Scanner(System.in);

    public static String getThreeNum() {
        return scan.nextLine();
    }

    public static boolean isNumber(String num) throws NumberFormatException {
        try {
            Integer.parseInt(num);
        } catch (NumberFormatException e) {
            throw new NumberFormatException("不是数字!");
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    public static boolean isGReaterThanZore(int num) throws LessThanZero {
        if (num <= 0) {
            throw new LessThanZero();
        }
        return true;
    }

    public static boolean isTriangle(int num1, int num2, int num3) throws NotTriangle{
        if (!(num1+num2 > num3 && num1 + num3 > num2 && num2+num3>num1)) {
            throw new NotTriangle();
        }
        return true;
    }

}
